package com.motorhome.h5.domain;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author: John
 */
@Data
public class Car implements Serializable, Comparable<Car> {

    private Long id;

    private String name;

    private String description;

    private String picUrl;

    private String viewUrl;

    private Float insurance;

    private int carNum;

    private List<Price> prices;

    @Override
    public int compareTo(Car o) {
        if (this.prices == null || this.prices.isEmpty()) {
            return -1;
        }
        if (o.prices == null || o.prices.isEmpty()) {
            return 1;
        }
        if (this.prices.get(0).getPrice() > o.prices.get(0).getPrice()) {
            return 1;
        }
        if (this.prices.get(0).getPrice().equals(o.prices.get(0).getPrice())) {
            return 0;
        }
        return -1;
    }
}
